package com.orientsec.autotest.project.system.sourcestrucdetail.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.orientsec.autotest.framework.aspectj.lang.annotation.Log;
import com.orientsec.autotest.framework.aspectj.lang.enums.BusinessType;
import com.orientsec.autotest.project.system.sourcestrucdetail.domain.Sourcestrucdetail;
import com.orientsec.autotest.project.system.sourcestrucdetail.service.ISourcestrucdetailService;
import com.orientsec.autotest.framework.web.controller.BaseController;
import com.orientsec.autotest.framework.web.page.TableDataInfo;
import com.orientsec.autotest.framework.web.domain.AjaxResult;
import com.orientsec.autotest.common.utils.poi.ExcelUtil;

/**
 * 数据源结构配置详情信息操作处理
 * 
 * @author autotest
 * @date 2019-12-30
 */
@Controller
@RequestMapping("/system/sourcestrucdetail")
public class SourcestrucdetailController extends BaseController
{
    private String prefix = "system/sourcestrucdetail";
	
	@Autowired
	private ISourcestrucdetailService sourcestrucdetailService;
	
	@RequiresPermissions("system:sourcestrucdetail:view")
	@GetMapping()
	public String sourcestrucdetail()
	{
	    return prefix + "/sourcestrucdetail";
	}
	
	/**
	 * 查询数据源结构配置详情列表
	 */
	@RequiresPermissions("system:sourcestrucdetail:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Sourcestrucdetail sourcestrucdetail)
	{
		startPage();
        List<Sourcestrucdetail> list = sourcestrucdetailService.selectSourcestrucdetailList(sourcestrucdetail);
		return getDataTable(list);
	}

	/**
	 * 查询目标文件结构配置详情列表
	 */
	@RequiresPermissions("system:sourcestrucdetail:list")
	@RequestMapping("/list/{id}")
	public String list(@PathVariable("id") Integer id,ModelMap mmap)
	{
		mmap.put("ssid",id);
		return prefix + "/sourcestrucdetail";
	}





	/**
	 * 导出数据源结构配置详情列表
	 */
	@RequiresPermissions("system:sourcestrucdetail:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Sourcestrucdetail sourcestrucdetail)
    {
    	List<Sourcestrucdetail> list = sourcestrucdetailService.selectSourcestrucdetailList(sourcestrucdetail);
        ExcelUtil<Sourcestrucdetail> util = new ExcelUtil<Sourcestrucdetail>(Sourcestrucdetail.class);
        return util.exportExcel(list, "sourcestrucdetail");
    }
	
	/**
	 * 新增数据源结构配置详情
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存数据源结构配置详情
	 */
	@RequiresPermissions("system:sourcestrucdetail:add")
	@Log(title = "数据源结构配置详情", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Sourcestrucdetail sourcestrucdetail)
	{		
		return toAjax(sourcestrucdetailService.insertSourcestrucdetail(sourcestrucdetail));
	}

	/**
	 * 修改数据源结构配置详情
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		Sourcestrucdetail sourcestrucdetail = sourcestrucdetailService.selectSourcestrucdetailById(id);
		mmap.put("sourcestrucdetail", sourcestrucdetail);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存数据源结构配置详情
	 */
	@RequiresPermissions("system:sourcestrucdetail:edit")
	@Log(title = "数据源结构配置详情", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Sourcestrucdetail sourcestrucdetail)
	{		
		return toAjax(sourcestrucdetailService.updateSourcestrucdetail(sourcestrucdetail));
	}
	
	/**
	 * 删除数据源结构配置详情
	 */
	@RequiresPermissions("system:sourcestrucdetail:remove")
	@Log(title = "数据源结构配置详情", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(sourcestrucdetailService.deleteSourcestrucdetailByIds(ids));
	}
	
}
